<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        body {
            /* margin-top: 100px; */
            width: 100%;
            height: 100%;
            /* height: 120px; */
            background: #000;
            color: white;
            /* border: 1px solid #ccc; */
        }
        
        button {
            margin-top: 5px;
            width: 60px;
            height: 20px;
            font-size: 12px;
            background: #ccc;
            border: 1px solid lightskyblue;
            color: #000;
            cursor: pointer;
        }
    </style>
</head>

<body>

    <button id="btn">开关灯</button> <br/> 你好吗？

    <script>
        // 获取按钮
        let btn = $("#btn")[0];
        // 获取box1盒子
        // let box1 = $(".box1")[0];
        let flag = true;
        btn.onclick = function() {
            if (flag) {
                document.body.style.background = "white";
                document.body.style.color = "#000";
            } else {
                document.body.style.background = "#000";
                document.body.style.color = "white";
            }
            flag = !flag;
        }

        function $(select) {
            return document.querySelectorAll(select);
        }
    </script>
</body>

</html>